package org.mm.repository;

import org.mm.model.User;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

public interface UserRepository extends PagingAndSortingRepository<User, Long> {

	@Query("select u from User u join fetch u.role r where u.userName = ?1 and u.userPassword = ?2 and u.userEnabled = true")
	public User findByUserNameAndUserPassword(String userName, String userPassword) throws Exception;
	
	@Query("select u from User u join fetch u.role r where u.userName = ?1 and u.userEnabled = true")
	public User findByUserName(String userName) throws Exception;

}
